import { defineConfig } from 'vite'
import { resolve } from "path";
import uni from '@dcloudio/vite-plugin-uni'

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    // 开发阶段启用源码映射：https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#需主动开启-sourcemap
    sourcemap: process.env.NODE_ENV === 'development',
  },
  plugins: [uni()],
  resolve: {
    alias: {
      // 配置别名
      "@": resolve(__dirname, "./src")
    }
  },
  server: {
    open: true, // 自动启动浏览器
    host: "0.0.0.0", // localhost
    port: 8012, // 端口号
    https: false,
    proxy: {
      "/api": {
        // target: "http://localhost:8080/",
        target: "http://localhost:7070/",
        // target: "http://139.159.228.183:8080/",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})
